<%--
  Created by IntelliJ IDEA.
  User: 你
  Date: 2020/10/23
  Time: 10:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<jsp:useBean id="User" class="com.media.bean.UserBean"></jsp:useBean>
<jsp:setProperty name="User" property="+"></jsp:setProperty>
<%
    Class.forName("com.mysql.jdbc.Driver")  ;

    String url="jdbc:mysql://localhost:3306/book";
    Connection connection= DriverManager.getConnection(url,"root","root");

    String sql="update user set username=?,password=?,gender=?,age=? where id=?";
    PreparedStatement ps=connection.prepareStatement(sql);

    ps.setString(1,User.getUsername());
    ps.setString(2,User.getPassword());
    ps.setString(3,User.getGender());
    ps.setInt(4,User.getAge());
    ps.setInt(5,User.getId());

    int count=ps.executeUpdate();
    if(count>0){
        out.print("修改成功");
    }else{
        out.print("修改失败");
    }
    response.setHeader("refresh","3;url=home.jsp");
%>
</body>
</html>
